package month4.day25;

import com.sun.xml.internal.ws.api.model.MEP;

import java.util.HashSet;
import java.util.Set;

public class Market {
    Set<Member> set=new HashSet<Member>();
    //开卡
    public boolean kaika(String name,String code){
        int jifen=100;
        Member member=new Member(name,code,jifen);
        return set.add(member);
    }
    //检验
    public Member jianyan(String name,String code){
        for(Member m:set){
            if(name.equals(m.getName())&&code.equals(m.getCode()))
                return m;
        }
        return null;
    }
    //修改密码
    public void xiugai(String name,String code,String newcode){
        Member m=jianyan(name,code);
        if(m==null)
            System.out.println("没有该用户");
        else {
             m.setCode(newcode);
            System.out.println("修改成功");
        }
    }
    //剩余积分
    public void shengyui(String name,String code){
        Member m=jianyan(name,code);
        if(m==null)
            System.out.println("没有该用户");
        else
            System.out.println("剩余积分："+m.getMinute());
    }
    //兑换
    public void duihuan(String name,String code){
        Member m=jianyan(name,code);
        if(m==null)
            System.out.println("没有该用户");
        else{

        }
    }
    //累积积分
    public void leiji(String name,String code){
        Member m=jianyan(name,code);
        if(m==null)
            System.out.println("没有该用户");
        else{

        }
    }
    //删除会员
    public boolean shanchu(String name,String code){
        Member m=jianyan(name,code);
        if(m==null)
            System.out.println("没有该用户");
        else{
            set.remove(m);
            System.out.println("删除成功");
            return true;
        }
        return false;
    }


}
